package com.fqcheng220.tools.babynamer;

public class Main {
    private String mChContain;
    private int mTotalCount = 3;

    public static void main(String[] args) {
        new Main().containsChar("烨").totalCount(3).start("程");
    }

    public Main containsChar(String ch) {
        mChContain = ch;
        return this;
    }

    public Main totalCount(int totalCount) {
        if (totalCount != 2 && totalCount != 3) {
            throw new RuntimeException("姓名只支持两个字或者三个字");
        }
        mTotalCount = totalCount;
        return this;
    }

    public void start(String xing) {
        String str = HanziTest.getAll();
        int count = 0;
        int matchedCount = 0;
        if (str != null) {
            int length = str.length();
            for (int i = 0; i < length; i++) {
                if (mTotalCount == 3) {
                    for (int j = 0; j < length; j++) {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.append(xing);
                        stringBuilder.append(str.charAt(i));
                        stringBuilder.append(str.charAt(j));
                        String name = stringBuilder.toString();
//                    System.out.println("第" + (count++) + "个:" + name);
                        boolean bSkip = false;
                        if (mChContain != null) {
                            bSkip = !mChContain.equals(String.valueOf(str.charAt(i))) && !mChContain.equals(String.valueOf(str.charAt(j)));
                        }
                        if (!bSkip && ShuLiChecker.check(name) == ShuLiChecker.CATEGORY.CAT_JIXIANG) {
                            System.out.println("多名----------第" + (matchedCount++) + "个:" + name);
                        }
                    }
                } else {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append(xing);
                    stringBuilder.append(str.charAt(i));
                    String name = stringBuilder.toString();
//                    System.out.println("第" + (count++) + "个:" + name);
                    if (ShuLiChecker.check(name) == ShuLiChecker.CATEGORY.CAT_JIXIANG) {
                        System.out.println("单名----------第" + (matchedCount++) + "个:" + name);
                    }
                }
            }
        }
    }
}
